package com.dwd.basic.utils;

import com.dwd.PetHomeApplication;
import com.dwd.user.pojo.LoginInfo;
import org.springframework.data.redis.core.RedisTemplate;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: TODO
 * @Author 汶狄
 * @Date 2021/1/24 15:53
 * @Version 1.0
 */

public class SystemContext {
    public static LoginInfo getLoginInfo(HttpServletRequest httpServletRequest) {
        RedisTemplate redisTemplate = PetHomeApplication.getRedisTemplate();
        //获取token
        String token = httpServletRequest.getHeader("token");
        //根据token查询对应的登陆用户
        LoginInfo loginInfo = (LoginInfo) redisTemplate.opsForValue().get(token);
        return loginInfo;
    }
}
